package com.dbuil.bleshoes.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dbuil.bleshoes.R;
import com.dbuil.bleshoes.bean.WuLiuBean;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class WuliuAdapter extends BaseQuickAdapter<WuLiuBean, BaseViewHolder> {
    public WuliuAdapter(@Nullable List<WuLiuBean> data) {
        super(R.layout.item_wuliu, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, WuLiuBean wuLiuBean) {

        ImageView imageView = baseViewHolder.getView(R.id.dot_iv);
        View dividerLineView = baseViewHolder.getView(R.id.divider_line_view);
        View timeLineView = baseViewHolder.getView(R.id.time_line_view);

        if (wuLiuBean.getStatus() == 0) {
            imageView.setImageResource(R.drawable.dot_red);
        } else {
            imageView.setImageResource(R.drawable.dot_black);
        }

        int position = baseViewHolder.getLayoutPosition();

        List<WuLiuBean> data = getData();
        if (position == data.size() - 1) {
            //最后一条数据，隐藏时间轴的竖线和水平的分割线
            timeLineView.setVisibility(View.INVISIBLE);
            dividerLineView.setVisibility(View.INVISIBLE);
        }
    }
}
